/**
 * 开垦
 */
class ConfirmPanel extends eui.Component {

    public constructor(msg: string, callback: Function) {
        super();
        this.skinName = ConfirmSkin;
        this.labMsg.text = msg;
        this.callback = callback;
    }


    private callback: Function;
    private labIcon: eui.Label;
    private labMsg: eui.Label;
    // 确定
    private labFirm: eui.Button;
    // 取消
    private labCancel: eui.Button;
    // 背景
    private rectBg: eui.Rect;


    protected createChildren() {
        super.createChildren();
        this.labFirm.addEventListener(egret.TouchEvent.TOUCH_TAP, this.firmTap, this);
        this.labCancel.addEventListener(egret.TouchEvent.TOUCH_TAP, this.cancelTap, this);

        // // 动画参数
        // var tween_time = 120;
        // var add_num = 50;

        // // 默认位置
        // var h = this.height;
        // var w = this.width;
        // var eh = this.rectBg.ellipseHeight;
        // var ew = this.rectBg.ellipseWidth;

        // var b = this.labMsg.bottom;
        // var mw = this.labMsg.width;

        // // 弹出动画
        // egret.Tween.get(this.rectBg)
        //     .to({ "ellipseHeight": h + add_num }, tween_time)
        //     .to({ "ellipseHeight": eh }, tween_time)
        //     .to({ "ellipseWidth": w + add_num }, tween_time)
        //     .to({ "ellipseWidth": ew }, tween_time);
        // egret.Tween.get(this.labMsg)
        //     .to({ "bottom": b + add_num }, tween_time)
        //     .to({ "bottom": b }, tween_time).call(() => {
        //         egret.Tween.get(this)
        //             .to({ "width": w + add_num })
        //             .to({ "width": w })
        //     });

    }



    /**
     * 确定
     */
    private firmTap() {
        SceneManager.ins.confirmClose();
        this.callback && this.callback(true);
    }



    /**
     * 取消
     */
    private cancelTap() {
        SceneManager.ins.confirmClose();
        this.callback && this.callback(false);
    }

}